<?php

session_start();

include_once "src/controller/blmanagement/UserAccountManagement.php";
include_once "src/model/User.php";
include_once "src/misc/ClientReponseGenerator.php";

try {

    $userAccounts = UserAccountManagement::getAllUsers();

    $items = "";
    $isFirstOne = true;
    for ($i = 0; $i < count($userAccounts); $i++) {
        $user = $userAccounts[$i];
        if ($user->getType() == 2) {
            if (!$isFirstOne) {
                $items .= ",";
                $isFirstOne = false;
            }
            $items .= "{\"id\":\"".$user->getUserId()."\", \"username\":\"".$user->getName()."\"}";
        }
    }

    echo ClientReponseGenerator::jsonResponse(1, $items, "", "");

} catch (Exception $e) {
    echo ClientReponseGenerator::simpleJsonResponse(0, "GetAllOwnersException", "");
}

?>
